package cn.edu.neu.config;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import cn.edu.neu.inteceptor.login_inteceptor;

@Configuration
public class MyMVCConfig implements WebMvcConfigurer {
    @Autowired
    private login_inteceptor login_inteceptor;

//    @Override
//    public void addViewControllers (ViewControllerRegistry registry){
////        registry.addViewController("/toLoginPage").setViewName("login");
////        registry.addViewController("/login.html").setViewName("login");
//
//    }
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        //registry.addInterceptor(inteceptor1).addPathPatterns("/**").excludePathPatterns("/login");
//        //registry.addInterceptor(inteceptor2).addPathPatterns("/toLoginPage");
//
//        InterceptorRegistration registration = registry.addInterceptor(login_inteceptor);
//        registration.addPathPatterns("/**"); //所有路径都被拦截
//        registration.excludePathPatterns( //添加不拦截路径
//                "/",
//                "/toRegister",
//                "/toRegist",
//                "/index",
//                "/toLogin", //登录页面
//                "/login",       //登录请求
//                "/**/*.html",   //html静态资源
//                "/**/*.js",     //js静态资源
//                "/**/*.png",
//                "/images/**",
//                "/**/*.css"     //css静态资源
//        );
//    }
}
